/**
 * Copyright 2009-2010 - YangJiandong(chunquedong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 你可以自由复制、传播本项目的下载包文件，但必须保持其完整性。
 * 我们不用对使用中的风险及由此造成的损失承担任何责任。
 * 详细情况请见《ChunMap许可协议》。

 * 想了解更多有关ChunMap的信息，请访问http://code.google.com/p/chunmap/
 */
package chunmap.model.relate.relateop;

import chunmap.model.geom.GeoPoint;
import chunmap.model.geom.Geometry;
import chunmap.model.geom.Ring;
import chunmap.model.geom.Polygon;
import chunmap.model.relate.ComputeIm;
import static chunmap.model.relate.IntersectionMatrix.*;

/**
 * disjion,within,onBoundary
 * 
 * @author chunquedong
 * 
 */
class Point_LinearRing extends ComputeIm {

	public Point_LinearRing(GeoPoint p1, Ring r2) {
		g1 = p1;
		g2 = r2.toPolygon();
	}

	@Override
	protected int inner2innerDim(Geometry g1, Geometry g2) {
		GeoPoint p1 = (GeoPoint) g1;
		Ring r2 = ((Polygon) g2).getShell();

		// 在边界
		if (im.get(Inner, Border) != EmptyDim)
			return EmptyDim;

		// 内部
		if (r2.containIn(p1.getCoordinate()))
			return PointDim;

		return EmptyDim;
	}

	@Override
	protected boolean within(Geometry g1, Geometry g2) {
		if (im.get(Inner, Border) != EmptyDim)
			return true;
		if (im.get(Inner, Inner) != EmptyDim)
			return true;
		else
			return false;
	}
}
